<?php

class goods extends model{
	static public function unsetfile($file){
		if (is_file(ROOT . '/temp/goods/' .$file.'.html')) {
			unlink(ROOT . '/temp/goods/' .$file.'.html');
		}
	} 

	public function addgoods($arr){
		if (is_array($arr)) {
			$bool = $this->querydata(array('goods_id')," where goods_name like '%".$arr[1]."%'");
			if (is_array($bool)) {
				return false;
			}
			$this->adddata(
				array(
						'goods_class'=>$arr[0],
						'goods_name' =>$arr[1],
						'goods_type' =>7,
						'goods_keymodel' =>1,
						'goods_image' =>'default.png'
					)
				);
			$id = $this->querymaxid();
			if ($id) {
				$message = new message('xxx_message');
				if ($arr[2]) {				
					$message->addmessage(array(
						'goods_id'=>$id,
						'type_id' =>2,
						'message_val' =>$arr[2]
					));
				}
				if ($arr[6]) {
					$message->addmessage(array(
						'goods_id'=>$id,
						'type_id' =>3,
						'message_val' =>$arr[6]
					));
				}
				if ($arr[8]) {
					$message->addmessage(array(
						'goods_id'=>$id,
						'type_id' =>4,
						'message_val' =>$arr[8]
					));
				}
				if ($arr[4]) {
					$message->addmessage(array(
						'goods_id'=>$id,
						'type_id' =>5,
						'message_val' =>$arr[4]
					));
				}
				if ($arr[3]) {
					$message->addmessage(array(
						'goods_id'=>$id,
						'type_id' =>6,
						'message_val' =>$arr[3]
					));
				}
				if ($arr[7]) {
					$message->addmessage(array(
						'goods_id'=>$id,
						'type_id' =>7,
						'message_val' =>$arr[7]
					));
				}
				if ($arr[5]) {
					$message->addmessage(array(
						'goods_id'=>$id,
						'type_id' =>8,
						'message_val' =>$arr[5]
					));
				}
				$message->close();
			}		
			
		}
		

	}
}


?>